# -*- coding: utf-8 -*-
"""
@Time: 11/22/2018 3:57 PM
@Author: hejing
@Email: 2010jing@gmail.com
"""
from flask import request
from wtforms import Form

from app.libs.error_code import ParameterException


class BaseForm(Form):

	def __init__(self):
		data = request.json
		super(BaseForm, self).__init__(data=data)

	def validate_for_api(self):
		valid = super(BaseForm, self).validate()
		if not valid:
			raise ParameterException(msg=self.errors)
		return self



